Sound PreMixer effect is a sample that shows how to make a pre-mixer component.
A pre-mixer component is a component that sees the sound data for a particular sound channel right before the data goes to the Apple Mixer component to be mixed with the sound data from all the other currently playing sound channels.
A pre-mixer component can do anything to the sound data it sees, _except_ generate more data (i.e., a reverb effect can't trail off longer than the original sound).
This pre-mixer sample implements a simple peak-hold meter. All it does is watch the sound stream coming by and find the largest sample value in the buffer. It remembers this value and when asked it will return what the peak sample value was.
A pre-mixer component is installed into a sound channel thusly:
When your application wants to talk to the pre-mixer effect component it does it like this:
theErr = SndGetInfo (theSndChannel, 'VMtr', &level); //get the VU-meter level
level will contain the peak level that the pre-mixer component saw in the previous buffer.
This is the best way to monitor the output of a specific sound channel.
Before you ask, there is no easy way to monitor the output of the Mixer component, though you might want to try to write an output component that takes over the real output component (that's the only thing I can think of that might work).
If you have any comments, questions, or bug reports please direct them to devsupport@apple.com.